package com.piggy.system.controller;

import com.piggy.common.core.web.controller.BaseController;
import com.piggy.common.core.web.domain.AjaxResult;
import com.piggy.common.satoken.annotation.Inner;
import com.piggy.common.core.domain.R;
import com.piggy.system.api.domain.SysRoleSceneRl;
import com.piggy.system.api.bo.SysRoleSceneRlQueryBo;
import com.piggy.system.domain.vo.SysRoleSceneRlVo;
import com.piggy.system.service.ISysRoleSceneRlService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/roleSceneRl")
public class SysRoleSceneRlController extends BaseController {
    @Autowired
    private ISysRoleSceneRlService service;

    @Inner
    @GetMapping("/getSceneRole")
    public AjaxResult getSceneRole(Long id){
        return AjaxResult.success(service.getSceneRole(id));
    }

    //@Inner
    @PostMapping("/addOrUpdateRole/{sceneId}")
    public AjaxResult addOrUpdateRole(@RequestBody List<SysRoleSceneRl> roleSceneRls, @PathVariable("sceneId") Long sceneId){
        return AjaxResult.success(service.addOrUpdateRole(roleSceneRls,sceneId));
    }

    @Inner
    @GetMapping("/activation")
    public int activation(Long sceneId){
        return service.activation(sceneId);
    }

    @Inner
    @PostMapping("/queryList")
    public R<List<SysRoleSceneRlVo>> queryList(@RequestBody SysRoleSceneRlQueryBo bo) {
        return R.ok(service.queryList(bo));
    }

}
